function template
<memory>

std::operator<< (shared_ptr)

template <class charT, class traits, class T>
  basic_ostream<charT,traits>& operator<< ( basic_ostream<charT,traits>& os, 
                                            const shared_ptr<T>& x );
Insert into output stream
Writes a system-specific textual representation of the stored pointer value, with the same effect as:

 
os << x.get();


Parameters

os
ostream object on which the insertion operation is performed.
x
A shared_ptr object.

Return Value

The same as parameter os.

If some error happens during the output operation, the stream's badbit flag is set, and if the appropriate flag has been set with ios::exceptions, an exception is thrown.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// shared_ptr i/o
#include <iostream>
#include <memory>

int main () {
  std::shared_ptr<int> foo (new int (10));

  std::cout << " foo: " << foo << '\n';
  std::cout << "*foo: " << *foo << '\n';

  return 0;
}


Possible output:
 foo: 0x920d90
*foo: 10

See also